package cn.com.headfree.sysmenu.dao.impl;

import cn.com.headfree.entity.IscUser;
import cn.com.headfree.entity.TOrgDept;
import cn.com.headfree.rzgl.dao.IRzglDao;
import cn.com.headfree.sysmenu.dao.IDeptUserDao;
import cn.com.headfree.sysmenu.vo.OrgDeptVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import com.gta.edu.sdk.common.dto.Page;
import com.gta.edu.sdk.util.StringUtil;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;


@Repository("deptUserDao")
public class DeptUserDaoImpl extends BaseDaoImpl<IscUser> implements IDeptUserDao {
    /**
     * 查询单位树信息
     * @param orgDept
     * @return
     */
    @Override
    public List<OrgDeptVo> searchDeptList(OrgDeptVo orgDept){
        ArrayList<Object> arrayList = new ArrayList<>();
        StringBuilder sqlbuilder = new StringBuilder(" SELECT TOD.id AS ID, TOD.name AS NAME, TOD.p_id AS P_ID, TOD.path AS PATH, TOD.level AS LEVEL ");
        sqlbuilder.append(" FROM t_org_dept TOD WHERE  TOD.path like concat('%',?,'%')  ORDER BY TOD.sort ASC ");
        arrayList.add(orgDept.getId());
        return this.findAllBySQL(OrgDeptVo.class, sqlbuilder.toString(), null, false, arrayList.toArray());
    }

}
